//package com.project.running.Config;
//
//import com.alibaba.druid.pool.DruidDataSource;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.PropertySource;
//import org.springframework.core.io.Resource;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import org.springframework.core.io.support.ResourcePatternResolver;
//
//import javax.sql.DataSource;
//import java.io.IOException;
//
///**
// * @Auther: hjy(lc))
// * @Date: 2022/10/17-10-17-20:04
// * @Description：com.example.config dao的配置文件  == spring-dao.xml
// * SqlSessionFactory Mapper
// */
//@Configuration
//@PropertySource("classpath:db.properties")
//@MapperScan("com.project.running.dao")
//public class DaoConfig {
//
//    @Value("${jdbc.driver}")
//    private String driverClassName;
//    @Value("${jdbc.url}")
//    private String url;
//    @Value("${jdbc.username}")
//    private String username;
//    @Value("${jdbc.password}")
//    private String password;
//
//    @Bean
//    public DataSource dataSource() {
//        DruidDataSource dataSource = new DruidDataSource();
//        dataSource.setDriverClassName(driverClassName);
//        dataSource.setUrl(url);
//        dataSource.setUsername(username);
//        dataSource.setPassword(password);
//        return dataSource;
//    }
//
//    @Bean
//    public SqlSessionFactoryBean sqlSessionFactoryBean() {
//        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
//        try {
//            // 数据源
//            sqlSessionFactoryBean.setDataSource(dataSource());
//            // 包别名
//            sqlSessionFactoryBean.setTypeAliasesPackage("com.project.running.bean");
//            // 映射文件扫描 classpath*:sqlmap/*-mapper.xml
//            ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
//            Resource[] resources = resolver.getResources("classpath:com/project/running/dao/*.xml");
//            sqlSessionFactoryBean.setMapperLocations(resources);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        return sqlSessionFactoryBean;
//    }
//}
